package cn.hr.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import cn.hr.utils.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import cn.hr.dao.mapper.WorMapper;
import cn.hr.pojo.Wor;
import cn.hr.service.WorService;

/**
 * 试题服务接口实现类
 *
 * @author MO
 */
@CacheConfig(cacheNames = "wor")
@Scope("prototype")
@Service("worService")
public class WorServiceImpl implements WorService {
    @Resource
    private WorMapper worMapper;

    @Override
    public boolean insert(Wor t) throws Exception {
        return worMapper.insert(t)>0;
    }

    @Override
    public boolean update(Wor t) throws Exception {
        return worMapper.update(t)>0;
    }

    @Override
    public boolean delete(Integer id) throws Exception {
        return worMapper.delete(id)>0;
    }


    @Override
    public Wor get(Integer id) throws Exception {
        return worMapper.get(id);
    }

    @Override
    public PageInfo<Map> findListByCondition(Map m, int pageNo) throws Exception {
        PageHelper.startPage(pageNo, Constants.PAGESIZE);
        List<Map> list = worMapper.findListByCondition(m);
        PageInfo<Map> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Long findCountByCondition(Map m) throws Exception {
        return null;
    }
    public  boolean updateByNull(Integer id){
        return worMapper.updateByNull(id)>0;
    }
}
